#!/bin/bash
echo -e "\e[32m=========开始安装docker==========\e[0m"
if docker -v &>/dev/null
then
        echo -e "\e[32m=======docker安装完成==========\e[0m"
        exit
fi
#安装docker
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
yum makecache fast
yum -y install docker-ce
service docker start
systemctl enable docker

#配置阿里云加速器
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://9rd9tz6h.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker
echo -e "\e[32m=========docker安装完成==========\e[0m"